package com.jp.knowledge.comm;

import com.jp.knowledge.model.InfoData;
import com.jp.knowledge.model.InfoDetailStateModel;
import com.jp.knowledge.model.TopicInfo;
import com.jp.knowledge.model.TopicListInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 528787067@qq.com on 2017/1/9.
 */
public class InfoDetailData {

    private static InfoDetailData infoDetailData = new InfoDetailData();
    private InfoDetailData(){};
    public static InfoDetailData getInfoDetail(){
        return infoDetailData;
    }

    private String linkIcon;
    private String linkId;
    private String linkTitle;
    private int linkType;
    public void setLinkIcon(String linkIcon){
        this.linkIcon = linkIcon;
    }
    public String getLinkIcon(){
        return this.linkIcon;
    }
    public void setLinkId(String linkId){
        this.linkId = linkId;
    }
    public String getLinkId(){
        return this.linkId;
    }
    public void setLinkTitle(String linkTitle){
        this.linkTitle = linkTitle;
    }
    public String getLinkTitle(){
        return this.linkTitle;
    }
    public void setlinkType(int linkType){
        this.linkType = linkType;
    }
    public int getLinkType(){
        return this.linkType;
    }

    /* 话题数据 */
    private TopicInfo topicInfo;
    public void setTopicInfo(TopicInfo topicInfo){
        this.topicInfo = topicInfo;
        hasTopicData = true;
    }
    public TopicInfo getTopicInfo(){
        if(this.topicInfo == null)
            this.topicInfo = new TopicInfo();
        return this.topicInfo;
    }
    private boolean hasTopicData = false;
    public boolean hasTopicData(){
        return this.hasTopicData;
    }

    /* 详情数据 */
    private InfoData infoData;
    public void setInfoData(InfoData infoData){
        this.infoData = infoData;

        if(infoData.getInfoPic() != null && infoData.getInfoPic().trim().length() > 0)
            setLinkIcon(infoData.getInfoPic());
        if(infoData.getTitle() != null && infoData.getTitle().trim().length() > 0)
            setLinkTitle(infoData.getTitle());
        if(infoData.getId() != null && infoData.getId().trim().length() > 0)
            setLinkId(infoData.getId());
        if(infoData.getType() != getLinkType())
            setlinkType(infoData.getType());
    }
    public InfoData getInfoData(){
        if(this.infoData == null)
            this.infoData = new InfoData();
        return this.infoData;
    }

    /* 话题列表 */
    List<TopicListInfo> topicList;
    public void setTopicList(List<TopicListInfo> topicList){
        this.topicList = topicList;
    }
    public List<TopicListInfo> getTopicList(){
        if(this.topicList == null)
            this.topicList = new ArrayList<>();
        return this.topicList;
    }

    /* 资讯详情状态 */
    InfoDetailStateModel infoDetailStateModel;
    public void setInfoDetailStateModel(InfoDetailStateModel infoDetailStateModel){
        this.infoDetailStateModel = infoDetailStateModel;
    }
    public InfoDetailStateModel getInfoDetailStateModel(){
        if(this.infoDetailStateModel == null)
            this.infoDetailStateModel = new InfoDetailStateModel();
        return this.infoDetailStateModel;
    }

    public void release(){
        linkIcon = null;
        linkId = null;
        linkTitle = null;
        linkType = 0;

        infoData = null;
        topicList = null;
        topicInfo = null;
    }
}
